using System;
using System.Collections.Generic;
using UnityEngine;
 
public class ConsultantManager {
	private Dictionary<string,KICOITConsultant> registeredConsultants;

	public ConsultantManager () {
		registeredConsultants = new Dictionary<string, KICOITConsultant> ();
	}

	public void ClearConsultants () {
		registeredConsultants.Clear ();
	}

	public bool Register(KICOITConsultant c) {
		if (c.DisplayName != "" && !registeredConsultants.ContainsKey (c.DisplayName)) {
			registeredConsultants.Add (c.DisplayName, c);
			return true;
		} 
		return false;
	}

	public List<string> GetConsultantList () {
		//TODO group alphabeticly with KICOIT listed first
		return new List<string> (registeredConsultants.Keys);
	}

	public KICOITConsultant GetConsultant (string key) {
		return registeredConsultants[key];	
	}
	public void drawConsultant(string key, ShipData s) {
		if (registeredConsultants.ContainsKey(key)) {
			registeredConsultants[key].DisplayUI(s);
		} else {
			GUILayout.Label("Missing: " + key);
		}
	}
	
	public void AnalizePart (Part p, ShipData s) {
		foreach (KICOITConsultant c in registeredConsultants.Values) {
			c.AnalizePart (p, s);
		}
	}

	public void AnalizeShip (ShipData s) {
		foreach (KICOITConsultant c in registeredConsultants.Values) {
			c.AnalizeShip (s);
		}
	}

}

